package br.net.woodstock.tickettoride.client.jdk6.ws.jee;

import java.util.Date;
import java.util.GregorianCalendar;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

abstract class TicketWSHelper {

	private static final DatatypeFactory	DATATYPE_FACTORY;

	static {
		try {
			DATATYPE_FACTORY = DatatypeFactory.newInstance();
		} catch (DatatypeConfigurationException e) {
			throw new RuntimeException(e);
		}
	}

	public static XMLGregorianCalendar toCalendar(final Date date) {
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.setTime(date);

		return TicketWSHelper.DATATYPE_FACTORY.newXMLGregorianCalendar(calendar);
	}

}
